package org.company.tool.service;

import org.apache.commons.lang3.StringUtils;
import org.company.tool.bean.Entity;

/**
 * nameTransfer规则
 * 根据表名，生成action,service,sqlMap等名称的统一规则接口
 * @author hucw
 *
 */
public abstract class NameTransfer {
    
    private Entity entity;
    
    private StringBuffer sb = new StringBuffer();
    
    public String getActionPackage() {
        sb.delete(0, sb.length());
        sb.append(entity.getPackageName()).
                    append("web.action.").append(StringUtils.uncapitalize(entity.getJavaName()));
        return sb.toString();
    }
    
    public String getBeanPackage() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append(".persistence.po");
        return sb.toString();
    }
    
    public String getIDaoPackage() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append(".persistence.dao");
        return sb.toString();
    }
    
    public String getIServicePackage() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append(".web.service");
        return sb.toString();
    }
    
    public String getDaoPackageImpl() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append(".persistence.dao.impl");
        return sb.toString();
    }
    
    public String getServicePackageImpl() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append(".web.service.impl");
        return sb.toString();
    }
    
    public String getSqlMapPackage() {
        sb.delete(0, sb.length());
        sb.append(entity.getPackageName()).append(".persistence.sql");
        return sb.toString();
    }
    
    public String getBeanName() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append("PO");
        return sb.toString();
    }
    
    public String getActionName() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append("Action");
        return sb.toString();
    }
    
    public String getIServiceName() {
        sb.delete(0, sb.length());
        sb.append("I");
        sb.append(entity.getJavaName()).append("Service");
        return sb.toString();
    }
    
    public String getIDaoName() {
        sb.delete(0, sb.length());
        sb.append("I");
        sb.append(entity.getJavaName()).append("DAO");
        return sb.toString();
    }
    
    public String getServiceNameImpl() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append("ServiceImpl");
        return sb.toString();
    }
    
    public String getDaoNameImpl() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append("DAOImpl");
        return sb.toString();
    }
    
    public String getBeanObject() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName());
        return StringUtils.uncapitalize(sb.toString());
    }
    
    public String getDaoObject() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append("DAO");
        return StringUtils.uncapitalize(sb.toString());
    }
    
    public String getServiceObject() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName()).append("Service");
        return StringUtils.uncapitalize(sb.toString());
    }
    
    public String getJspDir() {
        sb.delete(0, sb.length());
        sb.append(entity.getJavaName());
        return StringUtils.uncapitalize(sb.toString());
    }
    
    public String getJsDir() {
        sb.delete(0, sb.length());
        sb.append("js");
        return StringUtils.uncapitalize(sb.toString());
    }
}
